import request from '@/utils/axios/index'
import type { Dayjs } from 'dayjs'

/** 拓展目标信息 */
export interface ExpandTarget {
  id: number // ID
  name: string // 终端名称
  type: string // 终端类型:1.客户;2.渠道;3合作伙伴
  detailId: number // 详情id
  directorName: string // 负责人姓名
  contactNumber: string // 联系人电话
  address: string // 地址
  ownerUserId: number // 终端创建人id
  ownerUserName: string // 终端创建人姓名
  lastExpandTime: string | Dayjs // 最后一次拓展时间
}

// 拓展目标 API
export const ExpandTargetApi = {
  // 查询拓展目标分页
  getExpandTargetPage: async (params: any) => {
    return await request.get({ url: `/san/biz-expand-target/page`, params })
  },

  // 查询拓展目标详情
  getExpandTarget: async (id: number) => {
    return await request.get({ url: `/san/biz-expand-target/get?id=` + id })
  },

  // 新增拓展目标
  createExpandTarget: async (data: ExpandTarget) => {
    return await request.post({ url: `/san/biz-expand-target/create`, data })
  },

  // 修改拓展目标
  updateExpandTarget: async (data: ExpandTarget) => {
    return await request.put({ url: `/san/biz-expand-target/update`, data })
  },

  // 删除拓展目标
  deleteExpandTarget: async (id: number) => {
    return await request.delete({ url: `/san/biz-expand-target/delete?id=` + id })
  },

  /** 批量删除拓展目标 */
  deleteExpandTargetList: async (ids: number[]) => {
    return await request.delete({ url: `/san/biz-expand-target/delete-list?ids=${ids.join(',')}` })
  },

  // 导出拓展目标 Excel
  exportExpandTarget: async (params) => {
    return await request.download({ url: `/san/biz-expand-target/export-excel`, params })
  },

  // 查询大屏拓展客户分页
  getExpandTargetViewPage: async (params: any) => {
    return await request.post({ url: `/san/biz-expand-target-view/page`, params })
  },

  // 导出大屏拓展客户 Excel
  exportExpandTargetView: async (params) => {
    return await request.downloadPost({ url: `/san/biz-expand-target-view/export-excel`, params })
  },

  // 获取本月拓展，本月拜访，签约户数，签约金额，上月签约户数，本月到期收款，逾期未续签，到期续签
  getCountSum: async (params: any) => {
    return await request.post({ url: `/san/biz-expand-target-view/getCountSum`, params })
  },

  // 查询大屏拓展客户分页
  getContractArchiveViewList: async (params: any) => {
    return await request.post({ url: `/san/biz-expand-target-view/getContractArchiveViewList`, params })
  },

  // 本月到期收款列表
  getContractReceiveRecordViewList: async (params: any) => {
    return await request.post({ url: `/san/biz-expand-target-view/getContractReceiveRecordViewList`, params })
  },

  // 获取一年拓展用户数拓展次数月份统计
  getTotalAmount: async (params: any) => {
    return await request.post({ url: `/san/biz-expand-target-view/getTotalAmount`, params })
  },

}
